package com.gaogzhen.config.common;

import cn.hutool.core.lang.Snowflake;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Administrator
 * @date 2022-11-30 12:00
 */

@Configuration
public class IdConfig {
    @Value("${id.snowflake.appId}")
    private Integer appId;

    @Value("${id.snowflake.machineId}")
    private Integer machineId;

    /**
     * 雪花算法
     */
    @Bean
    public Snowflake snowflake() {
        return new Snowflake(appId, machineId);
    }
}
